<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.3.1.js"></script>
    <script>
        $(f);

        function f(){
            $("#d1").click(d1Click);
            $("input").keydown(inputKeyDown);
        }

        function inputKeyDown(e){
            if(e.keyCode>=65&&e.keyCode<=67){

            }else {
                 e.preventDefault(); //阻止默认事件
            }
        }

        function d1Click(){
            alert(1);
        }
    </script>
</head>
<body>

<div id="d1">123</div>

<input placeholder="只能输入a或b或c" />
</body>
</html>




